package javabase.desginpattern.structure.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fance
 * @date 18-4-28 下午1:32
 */
public class MarketBranch extends Market {
    List<Market> marketList = new ArrayList<>();

    public MarketBranch(String s) {
        this.name = s;
    }

    @Override
    public void add(Market m) {
        marketList.add(m);
    }

    @Override
    public void remove(Market m) {
        marketList.remove(m);
    }

    @Override
    public void payByCard() {
        System.out.println(name + " 消费,积分已累加入该会员卡");
        for (Market m: marketList
             ) {
            m.payByCard();
        }
    }
}
